try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
- let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
+ let root = try!(find_root_manifest_for_wd(options.flag_manifest_path,
+ config.cwd()));
let opts = CompileOptions {
config: config,
use cargo::ops;
use cargo::util::{CliResult, Config};
-use cargo::util::important_paths::{find_root_manifest_for_cwd};
+use cargo::util::important_paths::{find_root_manifest_for_wd};
#[derive(RustcDecodable)]
struct Options {
try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
- let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
+ let root = try!(find_root_manifest_for_wd(options.flag_manifest_path,
+ config.cwd()));
let mut doc_opts = ops::DocOptions {
open_result: options.flag_open,
{
let mut config = None;
let result = (|| {
- let cwd = try!(env::current_dir().chain_error(|| {
- human("couldn't get the current directory of the process")
- }));
- config = Some(try!(Config::new(shell(Verbose, Auto), cwd)));
+ config = Some(try!(Config::default()));
let args: Vec<_> = try!(env::args_os().map(|s| {
s.into_string().map_err(|s| {
human(format!("invalid unicode in argument: {:?}", s))
use rustc_serialize::{Encodable,Encoder};
use toml;
+use core::shell::{Verbosity, ColorConfig};
use core::{MultiShell, Package};
use util::{CargoResult, ChainError, Rustc, internal, human, paths};
}
impl Config {
- pub fn new(shell: MultiShell, cwd: PathBuf) -> CargoResult<Config> {
+ pub fn new(shell: MultiShell,
+ cwd: PathBuf,
+ homedir: PathBuf) -> CargoResult<Config> {
let mut cfg = Config {
- home_path: try!(homedir(cwd.as_path()).chain_error(|| {
- human("Cargo couldn't find your home directory. \
- This probably means that $HOME was not set.")
- })),
+ home_path: homedir,
shell: RefCell::new(shell),
rustc_info: Rustc::blank(),
cwd: cwd,
Ok(cfg)
}
+ pub fn default() -> CargoResult<Config> {
+ let shell = ::shell(Verbosity::Verbose, ColorConfig::Auto);
+ let cwd = try!(env::current_dir().chain_error(|| {
+ human("couldn't get the current directory of the process")
+ }));
+ let homedir = try!(homedir(&cwd).chain_error(|| {
+ human("Cargo couldn't find your home directory. \
+ This probably means that $HOME was not set.")
+ }));
+ Config::new(shell, cwd, homedir)
+ }
+
pub fn home(&self) -> &Path { &self.home_path }
pub fn git_db_path(&self) -> PathBuf {
}
fn scrape_rustc_version(&mut self) -> CargoResult<()> {
- self.rustc_info = try!(Rustc::new(&self.rustc, self.cwd()));
+ self.rustc_info = try!(Rustc::new(&self.rustc));
Ok(())
}
///
/// If successful this function returns a description of the compiler along
/// with a list of its capabilities.
- pub fn new<P: AsRef<Path>>(path: P, cwd: &Path) -> CargoResult<Rustc> {
+ pub fn new<P: AsRef<Path>>(path: P) -> CargoResult<Rustc> {
let mut cmd = util::process(path.as_ref());
- cmd.cwd(cwd).arg("-vV");
+ cmd.arg("-vV");
let mut ret = Rustc::blank();
let mut first = cmd.clone();
mod test_cargo_version;
mod test_shell;
-thread_local!(static RUSTC: Rustc = Rustc::new("rustc", &support::cwd()).unwrap());
+thread_local!(static RUSTC: Rustc = Rustc::new("rustc").unwrap());
fn rustc_host() -> String {
RUSTC.with(|r| r.host.clone())